<template>
	<b-layout-index>

		<navbar></navbar>

		<view class="bg-white pd-top-10">
			<view class="ltr">
				<u-search @search="searchByPhone" :showAction="false" :clearabled="true"></u-search>
			</view>
			<u-cell-group>
				<u-cell  :url="'./show?id='+item.id" v-for="(item,index) in datalist" isLink>
					<u-avatar v-if="item.avatar" fontSize="12" :random-bg-color="true" default-url="سس"
						:src="item.avatar" shape="square" slot="icon" randomBgColor>
					</u-avatar>
					<u-avatar v-else fontSize="12" text="头像" shape="square" slot="icon" randomBgColor>
					</u-avatar>
					<view slot="title">
						<view class="pd-left-5 pd-right-5 font-bold ma">{{item.name}}
						</view>
					</view>
					<view slot="value">
						<u-tag size="mini" plain :text="item.agentName"></u-tag>
					</view>
				</u-cell>

			</u-cell-group>
		</view>
	</b-layout-index>
</template>

<script>
	import {
		findByPageBackAgentMiniList
	} from "@/api/user.js";
	export default {
		data() {
			return {
				datalist: [],
				page: 0,
				phone: ""
			}
		},
		onLoad: function() {
			this.fetchByDataList()
		},
		onReachBottom: function() {
			var page = this.page;
			if (page > -1) {
				page++;
				this.page = page;
				this.fetchByDataList()
			}
			console.log("onReachBottom")
		},
		methods: {
			searchByPhone: function(e) {
				console.log(e)
				this.page = 0;
				this.datalist = []
				this.fetchByDataList(e)
			},
			fetchByDataList: function(value = "") {
				var datalist = this.datalist;
				findByPageBackAgentMiniList(this.page, value).then(res => {

					if (res.length < 10) {
						this.page = -1
					}
					datalist = datalist.concat(res)
					this.datalist = datalist
				})
			}
		}
	}
</script>

<style>
</style>
